package dbmanager;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import framework.Recipe;

public class PreferenceManager extends DatabaseObjectManager {
	
	public static ArrayList<Recipe> getNotDislikedRecipes(int id) throws SQLException {

			ResultSet srs = dbm
					.sendQuery("select * from recipe where id not in "
							+ "(select recipe_id from recipe_has_recipe_tags, recipe_tags where recipe_has_recipe_tags.tag_id=recipe_tags.id and tag in "
							+ "(select tag from recipe_pref, pref where pref.id = recipe_pref.id and is_liked = 0 "
							+ "and user_id = " + id +"));");

			ArrayList<Recipe> recipeList = new ArrayList<Recipe>();
			while (srs.next()) {
				recipeList.add(new Recipe(srs));
			}

			return recipeList;
		
	}
	
	public static void main(){
		try {
			System.out.println(getNotDislikedRecipes(7));
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

}
